//
//  XPDemoCode.swift
//  PPKit
//
//  Created by xiaopin on 2020/6/4.
//  Copyright © 2020 scoresdata.net. All rights reserved.
//

/*
 
 IOS弹出菜单：
 
 @IBAction func jubaoAction(_ sender: UIButton) {
     self.becomeFirstResponder()
     let menuVC = UIMenuController.shared
     let item1 = UIMenuItem(title: "复制", action: #selector(copyAction))
     let item2 = UIMenuItem(title: "举报", action: #selector(jubaoAction))
     menuVC.menuItems = [item1,item2]
     menuVC.setTargetRect(pp_frame(pp_screen_width - 90,20,90,50), in: self.contentView)
     menuVC.setMenuVisible(true, animated: true)
 }
 
 复制：
 func copyAction(){
     let board = UIPasteboard.general
     board.string = self.modelObj?.content!
     let menu = UIMenuController.shared
     menu.setMenuVisible(false, animated: true)
 }
 
 override var canBecomeFirstResponder: Bool{
     return true
 }
 
 override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
     if action == #selector(copyAction) {
         return true
     }
     if action == #selector(jubaoAction) {
         return true
     }
     return false
 }
 
 反射：
 let user1 = User()
 user1.name = "hangge"
 user1.age = 100
 user1.nickname = "xiaoming"
 user1.emails = ["hangge@hangge.com","system@hangge.com"]
         
 let mirror = Mirror(reflecting: user1)
         
 print("对象类型：\(mirror.subjectType)")
 print("对象子元素个数：\(mirror.children.count)")
         
 print("--- 对象子元素的属性名和属性值分别如下 ---")
 for case let (label?, value) in mirror.children {
     let mi = Mirror(reflecting: value)
     if mi.displayStyle != Mirror.DisplayStyle.optional {
        print("属性：\(label)  值：\(value)")
     } else {
        let (_, some) = mi.children.first!
        print("属性：\(label)  值：\(some)")
     }
 }
 
 对象类型：User
 对象子元素个数：4
 --- 对象子元素的属性名和属性值分别如下 ---
 属性：name  值：hangge
 属性：nickname  值：xiaoming
 属性：age  值：100
 属性：emails  值：["hangge@hangge.com", "system@hangge.com"]
 **/
